<template>
    <div class="app-container">
      <el-card shadow="hover">
        <el-form inline class="demo-form-inline">
          <el-form-item label="日期">
            <el-date-picker v-model="day" placeholder="选择日期时间" type="date" value-format="yyyy-MM-dd"/>
          </el-form-item>

          <el-form-item>
            <el-button :disabled="btnDisable" @click="create" type="primary" icon="el-icon-check">生成数据</el-button>
          </el-form-item>
        </el-form>

      </el-card>
    </div>
</template>

<script>
  import staApi from "@/api/edu/sta";

  export default {
    name: 'create',
    data(){
      return{
        //日期
        day: '',

        //判断按钮是否可用状态
        btnDisable: true,
      }
    },
    watch: {
      day(){
        if (this.day){
          this.btnDisable = false;
        }else {
          this.btnDisable = true;
        }
      }
    },
    methods: {
      //生成日期数据
      async create(){
        await staApi.createStaData(this.day);
        this.$message.success('获取数据成功');
        this.$router.push('/sta/list')
      },
    }
  }
</script>

<style scoped>

</style>
